<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Drag</title>
    <script src="../js/jquery.min.js"></script>
</head>
<body>
<style>
    .container {
        width: 200px;
        height: 200px;
        background: yellow;
    }

    .containerDrop {
        background-color: green;
    }

    .target {
        width: 100px;
        height: 100px;
        background-color: pink;
    }

    .hide {
        display: none;
    }
</style>
<div
        class="container"
        ondrop="drop(event)"
        ondragover="dragover(event)"
        ondragenter="dragenter(event)"
        ondragleave="dragleave(event)"
        ondragenter="dragendContainer(event)"
        id="container"></div>
<div class="target" id="target" draggable="true"
     ondragstart="dragstart(event)"
     ondragend="dragendTarget(event)"
     ondrag="drag(event)"
></div>
<img src="test.jpg" id="image" class="hide" alt="">
<script>
    var dragstart = function (e) {
        e.dataTransfer.setData("Text", e.target.id);
        e.dataTransfer.setDragImage($("#image").clone().removeClass('hide')[0], 0, 0);
    }
    var drop = function (e) {
        e.preventDefault();
        var data = e.dataTransfer.getData("Text");
        e.target.appendChild(document.getElementById(data))
    }
    var dragover = function (e) {
        e.preventDefault();
        $("#container").addClass("containerDrop");
    }
    var dragleave = function (e) {
        e.preventDefault();
        $("#container").removeClass("containerDrop");
    }
    var dragendContainer = function () {
        console.log('dragendContainer');
    }
    var drag = function () {
        console.log("drag")
    }
    var dragendTarget = function () {
        console.log("dragendTarget")
    }
</script>
</body>
</html>